import { BaseDeployPanel } from "./BaseDeployPanel";
import { Language } from "../../../../../../extend/language/Language";
import { EItemUpdateType } from "../../../../../../Message/Game/EItemUpdateType";
import { EquipAdvanceConfig } from "../../../../resource/EquipAdvanceConfig";
import { DataEvent } from "../../../../events/DataEvent";
import { EquipmentModuleConst } from "../../data/EquipmentModuleConst";
import { EquipmentItemDataUtil } from "../../../common/EquipmentItemDataUtil";
import { ItemData } from "../../../../resource/info/ItemData";
import { ShopConfig } from "../../../../resource/ShopConfig";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { EventName } from "../../../../mvc/EventName";
import { Cache } from "../../../../cache/Cache";
import { MsgManager } from "../../../../manager/MsgManager";
import { EProp } from "../../../../../../Message/Public/EProp";
import { EBind } from "../../../../../../Message/Public/EBind";
import { EquipUpdateParams } from "../../data/EquipUpdateParams";
import { PopupManager } from "../../../../manager/PopupManager";
import { EItemUpdateResult } from "../../../../../../Message/Game/EItemUpdateResult";
import { SoundManager } from "../../../../../common/sound/SoundManager";
import { SoundTypeConst } from "../../../../../common/sound/SoundTypeConst";
import { SPlayerItem } from "../../../../../../Message/Public/SPlayerItem";
import { JSON } from "../../../../../../com/mui/serialization/json/JSON";
import { HTMLUtil } from "../../../../../../com/gengine/utils/HTMLUtil";
import { ItemConfig } from "../../../../resource/ItemConfig";
import { ColorConfig } from "../../../../resource/ColorConfig";
import { GameDefConfig } from "../../../../resource/GameDefConfig";
import { AutoUpdateResultPanel } from "../../popupPanels/AutoUpdateResultPanel";
import { EffectManager } from "../../../../manager/EffectManager";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { FilterConst } from "../../../../../component/gconst/FilterConst";
import { GTextFormat } from "../../../../../common/GTextFormat";
import { GImageBitmap } from "../../../../../../com/mui/controls/GImageBitmap";
import { AttributeConfirmPanel } from "../AttributeConfirmPanel";
import { DeployPanelItem } from "../DeployPanelItem";
import { EquipPropButton } from "../EquipPropButton";
import { EquipmentSwordProgress } from "../EquipmentSwordProgress";
import { ObjCreate } from "../../../common/ObjCreate";
import { GameController } from "../../../../mvc/GameController";
import { TopStrengthenPanel } from "../../popupPanels/TopStrengthenPanel";
import { Alert } from "../../../../../../com/mui/controls/Alert";
import { NetDispatcher } from "../../../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../../../mvc/ServerCommand";
import { ECategory } from "../../../../../../Message/Public/ECategory";
import { GLabel } from "../../../../../../com/mui/controls/GLabel";
import { GButton } from "../../../../../../com/mui/controls/GButton";
type int = number;
//class StrenthenPanel
    
    export  class StrenthenPanel extends BaseDeployPanel
    {
        constructor()
        {
            this.posData = [{"x": 157, "y": 102, "label": Language.getString(60248), "canRemove": true, "noBoarder": false}, {"x": 54, "y": 176, "label": Language.getString(60249), "canRemove": false, "noBoarder": true, "showName": true}, {"x": 260, "y": 176, "label":"", "canRemove": true, "noBoarder": true}, {"x": 45, "y": 80, "label":"", "canRemove": false, "noBoarder": false}];
            this._alarmText = Language.getString(60147);
            super();
            this.addListeners();
            return;
        }

        public moveOutByIndex(arg1: int): void
        {
            if (arg1 >= 0 && arg1 < 3) 
            {
                if (arg1 != 0) 
                {
                    allItem[arg1].itemData = null;
                    this.updateInfos();
                    this.updateStatus();
                }
                else 
                {
                    this.clear();
                }
            }
            return;
        }

        public moveOutByUid(arg1: string): void
        {
            var loc2=null;
            var loc1=0;
            while (loc1 < 3) 
            {
                loc2 = allItem[loc1 + 1].itemData;
                if (loc2 && loc2.uid == arg1) 
                {
                    this.moveOutByIndex(loc1);
                    break;
                }
                ++loc1;
            }
            return;
        }

        /* internal  */refreshUpdateConfigInfo(): void
        {
            var loc3=0;
            var loc4=0;
            var loc1=0;
            var loc2=allItem[0].itemData;
            if (loc2) 
            {
                loc3 = loc2.itemExInfo.strengthen;
                loc4 = this.strengthenUpdateType != EItemUpdateType._EItemUpdateRefresh ? loc3 + 1 : loc3;
                loc1 = EquipAdvanceConfig.instance.getStrengthenCost(loc4);
            }
            else 
            {
                loc1 = 0;
            }
            if (loc1 != _cost) 
            {
                _cost = loc1;
                dispatchEvent(new DataEvent(EquipmentModuleConst.Event_CostChange, _cost, false, true));
            }
            return;
        }

        /* internal  */updateInfos(): void
        {
            var loc2=0;
            var loc3=null;
            var loc4=0;
            if (allItem[0].itemData) 
            {
                this._levelNumitem.text = "+" + allItem[0].itemData.itemExInfo.strengthen;
            }
            else 
            {
                this._levelNumitem.text = "";
            }
            var loc1=allItem[0].itemData;
            if (loc1) 
            {
                loc2 = loc1.itemExInfo.hasOwnProperty("perfectStrengthen") ? loc1.itemExInfo.perfectStrengthen : 0;
                this._perfectnessProgress.setValue(loc2, 100);
                loc3 = new EquipmentItemDataUtil(loc1);
                allItem[3].itemData = loc3.getHighestEquip(this._operationId);
                loc4 = loc1.itemExInfo.hasOwnProperty("totalStrengthen") ? loc1.itemExInfo.totalStrengthen : 0;
                this._percentLabel.text = "+" + loc4 + "%";
            }
            else 
            {
                this._perfectnessProgress.setValue(0, 100);
                allItem[3].itemData = null;
                this._percentLabel.text = "";
            }
            return;
        }

        public /* override */ clear(): void
        {
            this.clearAllItem();
            this.refreshUpdateConfigInfo();
            this.updateStatus();
            this.updateInfos();
            this._useProtectPropNum = 0;
            this._useLukyPropBtn.visible = true;
            this._attributeConfirm.setBaseAttribute(null);
            this.dispatchEvent(new DataEvent(EquipmentModuleConst.Event_ChoosedEquimentChange, [], false, true));
            return;
        }

        public /* override */ setAutoChooseMaterial(arg1: Object): void
        {
            this._useItems = arg1.material as Array<any>;
            allItem[1].itemData = this._useItems[0] as ItemData;
            allItem[1].amount = 1;
            allItem[1].enabled = arg1.isEnough;
            this.updateInfos();
            this.updateStatus();
            return;
        }

        /* internal  */autoBuyMaterial(arg1: ItemData, arg2): void
        {
            var loc2=null;
            var loc1=ShopConfig.instance.getShopItemInfoByCode(arg1.itemCode);
            if (arg2 != this._strenthenBtn) 
            {
                loc2 = this.onItemBuySuccessAuto;
            }
            else 
            {
                loc2 = this.onItemBuySuccess;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.ShopMallBuyItem, {"shopItemInfo": loc1, "amount": 1, "callBack": loc2}));
            return;
        }

        public /* override */ setAutoChooseLuckTune(arg1: Object): void
        {
            var loc1=arg1.luckTune;
            if (loc1 && loc1.length > 0) 
            {
                allItem[2].itemData = loc1[0];
                this._useProtectPropNum = 1;
                this._useLukyPropBtn.visible = false;
            }
            else 
            {
                allItem[2].itemData = null;
                this._useProtectPropNum = 0;
                this._useLukyPropBtn.visible = true;
            }
            return;
        }

        /* internal  */onUsePropChange(arg1: DataEvent): void
        {
            this.useProtectPropNum = arg1.data as int;
            return;
        }

        /* internal  */onTopStrengthen(arg1: DataEvent): void
        {
            var loc7=null;
            var loc8=0;
            if (!Cache.instance.guide.guideEquipRefresh) 
            {
                if (allItem[1].itemData && !allItem[1].enabled && !Cache.instance.equipment.isAutoBuy) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(60257));
                    return;
                }
            }
            var loc1=(arg1.data as ItemData).posType;
            var loc2=Cache.instance.pack.backPackCache.getPropItems();
            var loc3;
            if (loc3 = Cache.instance.equipment.isUseBind_equip) 
            {
                loc2.sortOn("bind", Array.DESCENDING);
            }
            else 
            {
                loc2.sortOn("bind");
            }
            var loc4=new Array<any>();
            var loc5="";
            if (allItem[0].itemData) 
            {
                loc5 = allItem[0].itemData.uid;
            }
            if (allItem[1].itemData && allItem[1].enabled) 
            {
                loc8 = 0;
                while (loc8 < loc2.length) 
                {
                    if ((loc7 = loc2[loc8] as ItemData).itemInfo.item.type == EProp._EPropEquipStrengthenProp && loc7.itemInfo.item.itemLevel == allItem[1].itemData.itemInfo.item.itemLevel) 
                    {
                        if (!(!loc3 && loc7.bind == EBind._EBindYes)) 
                        {
                            loc4.push(loc7.uid);
                        }
                    }
                    ++loc8;
                }
            }
            if (allItem[2].itemData) 
            {
                loc4.push(allItem[2].itemData.uid);
            }
            var loc6;
            (loc6 = new EquipUpdateParams()).operationId = this._operationId;
            loc6.autoUpdate = true;
            loc6.equipPosType = loc1;
            loc6.equipUid = loc5;
            loc6.materials = loc4;
            loc6.target = this.strengthenUpdateType;
            loc6.num = this.useProtectPropNum;
            loc6.flag = loc6.num > 0 ? true : false;
            loc6.autoBuyTone = allItem[1].itemData.itemInfo.item.itemLevel > 10 ? false : Cache.instance.equipment.isAutoBuy;
            this.dispatchEvent(new DataEvent(EquipmentModuleConst.Event_DoUpdateEvent1, loc6, false, true));
            return;
        }

        public /* override */ onUpdateResult(arg1: int, arg2: Boolean, arg3, arg4: Array<any>): void
        {
            var loc1;
            if (!(loc1 = new ItemData(arg3)).itemInfo) 
            {
                return;
            }
            if (this._topStrengthenPanel) 
            {
                PopupManager.removePopup(this._topStrengthenPanel);
            }
            if (arg1 != EItemUpdateResult._EItemUpdateResultSuccess) 
            {
                MsgManager.showRollTipsMsg(Language.getString(60261));
            }
            else 
            {
                if (loc1.itemExInfo && loc1.itemExInfo.perfectStrengthen == 100) 
                {
                    SoundManager.instance.soundPlay(SoundTypeConst.StrengEquipmentPerfect);
                    this.dispatchEvent(new DataEvent(EquipmentModuleConst.Event_AddHintLabel, Language.getString(60259), false, true, false));
                    if (loc1.itemInfo.item.level >= 60 && loc1.itemExInfo.strengthen == 7) 
                    {
                        MsgManager.showTaskTarget(Language.getString(61030));
                    }
                }
                else 
                {
                    SoundManager.instance.soundPlay(SoundTypeConst.StrengEquipmentNotPerfect);
                }
                MsgManager.showRollTipsMsg(Language.getString(60260));
                addUpdateSuccessEffect("equipEffect_strengthen.swf", 185, 283);
                this.clear();
            }
            if (arg2) 
            {
                this.showOperationResult(arg1, arg3, arg4);
            }
            this.putInItem(loc1, true);
            return;
        }

        /* internal  */showOperationResult(arg1: int, arg2: SPlayerItem, arg3: Array<any>): void
        {
            var loc7=null;
            var loc8=null;
            var loc9=null;
            var loc10=null;
            var loc1="";
            var loc2;
            var loc3=(loc2 = JSON.deserialize(arg2.jsStr))["strengthen"];
            var loc4=loc2["perfectStrengthen"];
            var loc11=arg1;
            switch (loc11) 
            {
                case EItemUpdateResult._EItemUpdateResultSuccess:
                {
                    if (loc4 != 100) 
                    {
                        loc1 = loc1 + HTMLUtil.addColor(Language.getString(60263), "#00FF00");
                    }
                    else 
                    {
                        loc1 = loc1 + HTMLUtil.addColor(Language.getString(60262), "#ffba00");
                    }
                    break;
                }
                case EItemUpdateResult._EItemUpdateResultFail:
                {
                    loc1 = loc1 + HTMLUtil.addColor(Language.getString(60263), "#00FF00");
                    break;
                }
                case EItemUpdateResult._EItemUpdateResultLackCoin:
                {
                    loc1 = loc1 + HTMLUtil.addColor(Language.getString(60264), "#00FF00");
                    break;
                }
                case EItemUpdateResult._EItemUpdateResultLackLuckyProp:
                {
                    loc1 = loc1 + HTMLUtil.addColor(Language.getString(60265), "#00FF00");
                    break;
                }
            }
            loc1 = (loc1 = loc1 + "\n") + HTMLUtil.addColor(Language.getStringByParam(60266, loc3, loc4), "#B1efff");
            if (arg3.length > 0) 
            {
                loc1 = (loc1 = loc1 + "\n") + HTMLUtil.addColor(Language.getString(60267), "#b1efff");
                loc7 = new Map<any, any> /* flash.utils.Dictionary */();
                loc11 = 0;
                var loc12=arg3;
                for(loc9 of loc12) 
                {
                    var loc13=0;
                    var loc14=loc9.itemCodeAmountDict;
                    for (loc8 in loc14) 
                    {
                        loc10 = ItemConfig.instance.getInfoByCode(int(loc8)).item.name;
                        if (loc7[loc10]) 
                        {
                            loc7[loc10]["count"] = loc7[loc10]["count"] + loc9.itemCodeAmountDict[loc8];
                            continue;
                        }
                        loc7[loc10] = {"count": loc9.itemCodeAmountDict[loc8], "code": int(loc8)};
                    }
                }
                loc11 = 0;
                loc12 = loc7;
                for (loc8 in loc12) 
                {
                    loc1 = loc1 + (HTMLUtil.addColor(loc7[loc8]["count"], "#ff0000") + HTMLUtil.addColor(Language.getString(60268), "#b1efff") + HTMLUtil.addColor(loc8, ColorConfig.instance.getItemColorString(ItemConfig.instance.getInfoByCode(loc7[loc8]["code"]).item.color)) + HTMLUtil.addColor("，", "#b1efff"));
                }
                if (loc9) 
                {
                    loc1 = loc1 + (HTMLUtil.addColor(Language.getString(60269), "#b1efff") + HTMLUtil.addColor(String(loc9.cost), "#ff0000") + HTMLUtil.addColor(GameDefConfig.instance.getEPrictUnitName(loc9.unit), "#b1efff") + HTMLUtil.addColor("。", "#b1efff"));
                }
            }
            var loc5;
            (loc5 = new AutoUpdateResultPanel()).setResultText(loc1, Language.getString(60270));
            PopupManager.addPopUp(loc5, "", true);
            var loc6=this.localToGlobal(new Object /* flash.geom.Point */(this._topAdditionBtn.x, this._topAdditionBtn.y));
            loc5.x = loc6.x - loc5.btnOK.x;
            loc5.y = loc6.y - loc5.btnOK.y;
            if (Cache.instance.guide.guideEquipRefresh) 
            {
                loc5.guideEquipReq();
            }
            return;
        }

        public /* override */ guideEquipOpt(arg1: Function, arg2: Boolean): void
        {
            if (arg2) 
            {
                arg1(this._topAdditionBtn.x - 10, this._topAdditionBtn.y + this._topAdditionBtn.height / 2, this._topAdditionBtn, arg2, allItem[0].itemData);
            }
            else 
            {
                arg1(this._strenthenBtn.x - 10, this._strenthenBtn.y + this._strenthenBtn.height / 2, this._strenthenBtn, arg2, allItem[0].itemData);
            }
            return;
        }

        public /* override */ hideGuide(): void
        {
            EffectManager.glowFilterUnReg(this._strenthenBtn);
            EffectManager.glowFilterUnReg(this._topAdditionBtn);
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc5=null;
            var loc6=null;
            super.createChildren();
            var loc1=GlobalClass.getBitmap(ImagesConst.equipment_strengthen_qianghua);
            loc1.x = 236;
            loc1.y = 69;
            this.addChild(loc1);
            this._levelNumitem = new Object /* flash.text.TextField */();
            addChild(this._levelNumitem);
            this._levelNumitem.selectable = false;
            this._levelNumitem.x = 280;
            this._levelNumitem.y = 65;
            this._levelNumitem.width = 50;
            this._levelNumitem.height = 25;
            this._levelNumitem.filters = [FilterConst.glowFilter];
            var loc2=new GTextFormat();
            loc2.color = 6684448;
            loc2.size = 18;
            this._levelNumitem.defaultTextFormat = loc2;
            var loc3=new GImageBitmap("Label_jipingyulang.png", 16, 122);
            this.addChild(loc3);
            this._attributeConfirm = new AttributeConfirmPanel();
            this._attributeConfirm.x = 104;
            this._attributeConfirm.y = 148;
            this.addChild(this._attributeConfirm);
            var loc4=0;
            while (loc4 < this.posData.length) 
            {
                loc5 = this.posData[loc4];
                (loc6 = new DeployPanelItem(loc4, loc5.noBoarder, false, "", loc5.showName)).posIndex = loc4;
                loc6.x = loc5["x"];
                loc6.y = loc5["y"];
                loc6.label = loc5["label"];
                if (loc5.canRemove) 
                {
                    loc6.mouseEnabled = true;
                    loc6.addEventListener(flash.events.MouseEvent.CLICK, this.onItemClick);
                }
                addChild(loc6);
                allItem.push(loc6);
                ++loc4;
            }
            this._useLukyPropBtn = new EquipPropButton(Language.getString(60250));
            this._useLukyPropBtn.x = 261;
            this._useLukyPropBtn.y = 177;
            this.addChild(this._useLukyPropBtn);
            this._perfectnessProgress = new EquipmentSwordProgress();
            this._perfectnessProgress.x = 30;
            this._perfectnessProgress.y = 272;
            this._perfectnessProgress.setValue(0, 100);
            this.addChild(this._perfectnessProgress);
            ObjCreate.createLabel(Language.getString(60251), 216, 90, 100, 20, flash.text.TextFormatAlign.LEFT, this, true, 11661311);
            this._percentLabel = ObjCreate.createLabel("", 300, 90, 40, 20, flash.text.TextFormatAlign.LEFT, this, true, 16773396);
            this._strenthenBtn = ObjCreate.createGButton(Language.getString(60252), 68, 306, 75, 26, this, "ButtonSpecial");
            this._topAdditionBtn = ObjCreate.createGButton(Language.getString(60253), 216, 306, 75, 26, this, "ButtonSpecial");
            return;
        }

        /* internal  */addListeners(): void
        {
            this._attributeConfirm.addEventListener(EquipmentModuleConst.Event_AttributeConfirm, this.onAttributeConfirm);
            this._strenthenBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._topAdditionBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._useLukyPropBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            return;
        }

        public set strengthenUpdateType(arg1: int)
        {
            this._strengthenUpdateType = arg1;
            GameController.equipment.currentUpdateType = arg1;
            GameController.petEquip.currentUpdateType = arg1;
            this._attributeConfirm.setBaseAttribute(allItem[0].itemData);
            return;
        }

        public get strengthenUpdateType(): int
        {
            return this._strengthenUpdateType;
        }

        public get topStrengthenPanel(): TopStrengthenPanel
        {
            if (!this._topStrengthenPanel) 
            {
                this._topStrengthenPanel = new TopStrengthenPanel();
                this._topStrengthenPanel.addEventListener(EventName.Equipment_OnTopAddition, this.onTopStrengthen);
                this._topStrengthenPanel.addEventListener(EventName.Equipment_OnUsePropChange, this.onUsePropChange);
            }
            return this._topStrengthenPanel;
        }

        public get useProtectPropNum(): int
        {
            return this._useProtectPropNum;
        }

        public set useProtectPropNum(arg1: int)
        {
            this._useProtectPropNum = arg1;
            this.dispatchEvent(new DataEvent(EquipmentModuleConst.Event_LuckTuneNumChange, arg1, false, true, false));
            return;
        }

        /* internal  */onItemClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.currentTarget as DeployPanelItem;
            if (loc1.posIndex != 2) 
            {
                this.moveOutByIndex(loc1.posIndex);
            }
            else if (loc1.itemData) 
            {
                this.useProtectPropNum = 0;
            }
            else 
            {
                this.useProtectPropNum = 1;
            }
            return;
        }

        /* internal  */onAttributeConfirm(arg1: DataEvent): void
        {
            this.strengthenUpdateType = EItemUpdateType._EItemUpdateUpgrade;
            this.dispatchEvent(new DataEvent(EquipmentModuleConst.Event_ChoosedEquimentChange, [allItem[0].itemData], false, true));
            return;
        }

        /* internal  */onButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.onButtonClickImpl(arg1.currentTarget);
            return;
        }

        /* internal  */onButtonClickImpl(arg1): void
        {
            var target;
            var closeConfirmAlert: Function;
            var closeAutoConfirmAlert: Function;

            var loc1;
            target = arg1;
            if (!this.checkCanStrengthen(target)) 
            {
                return;
            }
            var loc2=target;
            switch (loc2) 
            {
                case this._strenthenBtn:
                {
                    if (!Cache.instance.guide.guideEquipRefresh && this.checkIsChangeToBind()) 
                    {
                        closeConfirmAlert = (arg1: int): void
                        {
                            if (arg1 == Alert.OK) 
                            {
                                onConfirmButtonClick();
                            }
                            return;
                        }
                        Alert.show(this._alarmText, null, Alert.OK | Alert.CANCEL, null, closeConfirmAlert);
                    }
                    else 
                    {
                        this.onConfirmButtonClick();
                    }
                    break;
                }
                case this._topAdditionBtn:
                {
                    if (this.checkIsChangeToBind()) 
                    {
                        closeAutoConfirmAlert = (arg1: int): void
                        {
                            if (arg1 == Alert.OK) 
                            {
                                onAutoConfirmButtonClick();
                            }
                            return;
                        }
                        Alert.show(this._alarmText, null, Alert.OK | Alert.CANCEL, null, closeAutoConfirmAlert);
                    }
                    else 
                    {
                        this.onAutoConfirmButtonClick();
                    }
                    break;
                }
                case this._useLukyPropBtn:
                {
                    this.useProtectPropNum = 1;
                    break;
                }
            }
            return;
        }

        /* internal  */checkCanStrengthen(arg1): Boolean
        {
            if (allItem[0].itemData == null) 
            {
                MsgManager.showRollTipsMsg(Language.getString(60254));
                return false;
            }
            if (allItem[1].itemData == null) 
            {
                return false;
            }
            if (allItem[0].itemData.itemExInfo.strengthen == 11 && this._strengthenUpdateType == EItemUpdateType._EItemUpdateUpgrade) 
            {
                MsgManager.showRollTipsMsg(Language.getString(60255));
                if (Cache.instance.guide.guideEquipRefresh) 
                {
                    Alert.show(Language.getString(60256), null, Alert.OK, null, this.onAlertCloseHandler);
                }
                return false;
            }
            if (allItem[1].enabled == false && !Cache.instance.guide.guideEquipRefresh) 
            {
                if (!Cache.instance.equipment.isAutoBuy) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(60257));
                    return false;
                }
                if (allItem[1].itemData && allItem[1].itemData.itemInfo.item.itemLevel == 11) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(60257));
                    return false;
                }
            }
            if (!isEnoughMoney && !Cache.instance.guide.guideEquipRefresh) 
            {
                MsgManager.showRollTipsMsg(Language.getString(60121));
                if (arg1 != this._useLukyPropBtn) 
                {
                    this.dispatchEvent(new DataEvent(EquipmentModuleConst.Event_CoinNotEnough, null, false, true, true));
                }
                return false;
            }
            return true;
        }

        public /* override */ clearAllItem(): void
        {
            super.clearAllItem();
            this._levelNumitem.text = "";
            return;
        }

        /* internal  */onItemBuySuccess(): void
        {
            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsChange, this.serverBagDataChangehandler);
            return;
        }

        /* internal  */onItemBuySuccessAuto(): void
        {
            NetDispatcher.addCmdListener(ServerCommand.BackPackItemsChange, this.serverBagDataChangehandlerAuto);
            return;
        }

        /* internal  */serverBagDataChangehandler(arg1): void
        {
            NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsChange, this.serverBagDataChangehandler);
            var loc1=allItem[0].itemData ? [allItem[0].itemData] : [];
            this.dispatchEvent(new DataEvent(EquipmentModuleConst.Event_ChoosedEquimentChange, loc1, false, true));
            this.onButtonClickImpl(this._strenthenBtn);
            return;
        }

        /* internal  */serverBagDataChangehandlerAuto(arg1): void
        {
            NetDispatcher.removeCmdListener(ServerCommand.BackPackItemsChange, this.serverBagDataChangehandlerAuto);
            var loc1=allItem[0].itemData ? [allItem[0].itemData] : [];
            this.dispatchEvent(new DataEvent(EquipmentModuleConst.Event_ChoosedEquimentChange, loc1, false, true));
            if (allItem[1].itemData && allItem[1].enabled) 
            {
                this.onTopStrengthen(new DataEvent("", allItem[0].itemData));
            }
            return;
        }

        /* internal  */onAlertCloseHandler(arg1: int): void
        {
            if (Cache.instance.guide.guideEquipRefresh) 
            {
                GameController.equipment.view.hide();
            }
            return;
        }

        /* internal  */onConfirmButtonClick(): void
        {
            var loc1=allItem[0].itemData.posType;
            var loc2=new Array<any>();
            var loc3="";
            if (allItem[0].itemData) 
            {
                loc3 = allItem[0].itemData.uid;
            }
            else 
            {
                return;
            }
            if (allItem[1].itemData && allItem[1].enabled) 
            {
                loc2.push(allItem[1].itemData.uid);
            }
            if (allItem[2].itemData) 
            {
                loc2.push(allItem[2].itemData.uid);
            }
            var loc4;
            (loc4 = new EquipUpdateParams()).operationId = this._operationId;
            loc4.autoUpdate = false;
            loc4.equipPosType = loc1;
            loc4.equipUid = loc3;
            loc4.materials = loc2;
            loc4.target = this.strengthenUpdateType;
            loc4.num = this.useProtectPropNum;
            loc4.flag = this.useProtectPropNum > 0 ? true : false;
            loc4.autoBuyTone = allItem[1].itemData.itemInfo.item.itemLevel > 10 ? false : Cache.instance.equipment.isAutoBuy;
            this.dispatchEvent(new DataEvent(EquipmentModuleConst.Event_DoUpdateEvent1, loc4, false, true));
            return;
        }

        /* internal  */onAutoConfirmButtonClick(): void
        {
            PopupManager.addPopUp(this.topStrengthenPanel, "window", true);
            this.topStrengthenPanel.imageItemData = allItem[0].itemData;
            var loc1=this.localToGlobal(new Object /* flash.geom.Point */(this._topAdditionBtn.x, this._topAdditionBtn.y));
            this.topStrengthenPanel.x = loc1.x - this.topStrengthenPanel.btnOK.x;
            this.topStrengthenPanel.y = loc1.y - this.topStrengthenPanel.btnOK.y;
            if (Cache.instance.guide.guideEquipRefresh) 
            {
                this.topStrengthenPanel.guideEquipReq();
            }
            return;
        }

        /* internal  */checkIsChangeToBind(): Boolean
        {
            var loc2=null;
            var loc1=false;
            var loc3=0;
            while (loc3 < this._useItems.length) 
            {
                loc2 = this._useItems[loc3] as ItemData;
                if (loc2.itemInfo.item.bind != EBind._EBindNo) 
                {
                    loc1 = true;
                }
                ++loc3;
            }
            if (!(allItem[0].itemData.itemExInfo.bind == EBind._EBindYes) && loc1) 
            {
                return true;
            }
            return false;
        }

        /* internal  */useNumChangeHandler(arg1: Object /* flash.events.Event */=null): void
        {
            this.dispatchEvent(new DataEvent(EquipmentModuleConst.Event_LuckTuneNumChange, this.useProtectPropNum, false, true));
            return;
        }

        protected /* override */ updateStatus(): void
        {
            super.updateStatus();
            return;
        }

        public /* override */ putInItem(arg1: ItemData, arg2: Boolean=false, arg3=null): void
        {
            var loc1=0;
            if (arg1.itemInfo.item.category == ECategory._ECategoryEquip || arg1.itemInfo.item.category == ECategory._ECategoryPetEquip) 
            {
                allItem[0].itemData = arg1;
                loc1 = arg1.itemExInfo.hasOwnProperty("perfectStrengthen") ? arg1.itemExInfo.perfectStrengthen : 0;
                if (arg1.itemExInfo.strengthen == 0 || loc1 == 100) 
                {
                    this.strengthenUpdateType = EItemUpdateType._EItemUpdateUpgrade;
                }
                else 
                {
                    this.strengthenUpdateType = EItemUpdateType._EItemUpdateRefresh;
                }
                this.refreshUpdateConfigInfo();
                this.updateInfos();
                this.updateStatus();
                this.dispatchEvent(new DataEvent(EquipmentModuleConst.Event_ChoosedEquimentChange, [arg1], false, true));
                if (arg2) 
                {
                    this._attributeConfirm.valueGlow();
                }
            }
            return;
        }

        public set operationId(arg1: int)
        {
            this._operationId = arg1;
            this._attributeConfirm.operationId = this._operationId;
            return;
        }

        /* internal */ /* var */_operationId: int=1;

        /* internal */ /* var */_levelNumitem: Object /* flash.text.TextField */;

        /* internal */ /* var */posData: Array<any>;

        /* internal */ /* var */_useLukyPropBtn: EquipPropButton;

        /* internal */ /* var */_alarmText: string;

        /* internal */ /* var */_useItems: Array<any>;

        /* internal */ /* var */_strengthLevelLabel: GLabel;

        /* internal */ /* var */_percentLabel: GLabel;

        /* internal */ /* var */_attributeConfirm: AttributeConfirmPanel;

        /* internal */ /* var */_strenthenBtn: GButton;

        /* internal */ /* var */_topAdditionBtn: GButton;

        /* internal */ /* var */_useProtectPropNum: int;

        /* internal */ /* var */_topStrengthenPanel: TopStrengthenPanel;

        /* internal */ /* var */_strengthenUpdateType: int;

        /* internal */ /* var */_perfectnessProgress: EquipmentSwordProgress;
    }
